<?php if (!defined('THINK_PATH')) exit();?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>订单填写</title>
        <link href="/favicon.ico" rel="shortcut icon">
        <link href="/favicon.ico" rel="subsection">
        <link href="/Public/Home/css/skins/lodomb_qj069/base/ui.all.css" type="text/css" rel="stylesheet">
        <link rel="stylesheet" href="/Public/Home/css/skins/lodomb_qj069/lodocs.css" type="text/css" />
        <link rel="stylesheet" href="/Public/Home/css/skins/lodomb_qj069/lodo_base.css" type="text/css" />
        <link rel="stylesheet" href="/Public/Home/css/skins/lodomb_qj069/lodo_cart.css" type="text/css" />
        

        
       
    <script type="text/javascript" src="/Public/static/jquery-2.0.3.min.js"></script>    
    </head>
    <body>
        <div id="topbar">
            <div class="wraper">
                <div class="fr">
                    <ul class="topnav">
                        <li>
                            <dl class="fl">
                                <dt><a href="/member/consume.asp">我的订单</a></dt>
                            </dl>
                        </li>

                    </ul>
                </div>
                <div class="user">
                    <a href="<?php echo U('Index/index');?>">
                        首页</a>
                </div>
            </div>
        </div>
        <div id="header" class="cart2">
            <div class="wraper">
                <a href="<?php echo U('Index/index');?>" style="background-image: url('/Public/Home/images/logo.gif');" class="logo inblock">仿l梨喂i网</a>

            </div>        
        </div>
        <!-- 顶部end -->
        
        


        <!--订单第二步-->
        <div class="web_body w">
            <div class="cart_body cart2">
                <div class="cart_info">
                    <form name="fmcart" id="fmcart" method="post" action="Savecart.asp">
                        <input type="hidden" name="pop_act" id="pop_act" value="0" />
                        <input type="hidden" name="pop_goodsid" id="pop_goodsid" value="0" />
                        <input type="hidden" id="cart_goods_total_price" value="233.24">
                        <!--收货人提交信息-->
                        <input type="hidden" name="u_c_name" id="u_c_name" value="">
                        <input type="hidden" name="u_c_addr" id="u_c_addr" value="">
                        <input type="hidden" name="u_c_zip" id="u_c_zip" value="">
                        <input type="hidden" name="u_c_tel" id="u_c_tel" value="">
                        <input type="hidden" name="u_c_mobile" id="u_c_mobile" value="">
                        <input type="hidden" name="u_c_mail" id="u_c_mail" value="">
                        <input type="hidden" name="u_c_region_list" id="u_c_region_list" value="">

                        <div class="rinfo cart_Consignee_info" id="u_c_info_edit" style="display: block">
                            <div class="rinfo_title">
                                <span class="o_t_left"><font>填写收货人信息:</font></span> <span class="o_t_right"></span>
                            </div>
                            <div class="rinfo_info" style="border:1px #ccc solid;">
                                <div class="sconsignee_list">
                                    <ul id="user_consignee_list">


                                        <li cid="208">
                                            <div class="left">
                                                <label for="user_consignee_id_208">
                                                    
                                                    <div class="u_c_info">
                                                    <?php if(is_array($addr)): $i = 0; $__LIST__ = $addr;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><div class="c_radio">
                                                        <input type="radio" name="user_consignee_id" id="user_consignee_id_208"
                                                           class="aid"    onfocus="this.blur();" value="<?php echo ($v["id"]); ?>">
                                                    </div>
                                                        <div class="u_c_list">
                                                            <div class="c_name">
                                                                <em>姓名：</em> <span><?php echo ($v["name"]); ?></span>
                                                            </div>
                                                            <div class="c_mobile">
                                                                <em>手机：</em> <span><?php echo ($v["tel"]); ?></span>
                                                            </div>
                                                            <div class="c_addr">
                                                                <em>地址：</em> <span><?php echo ($v["address"]); ?></span>
                                                            </div>

                                                            <div  class="c_zip">
                                                                <em>邮编：</em> <span><?php echo ($v["email"]); ?></span>
                                                            </div>

                                                        </div><?php endforeach; endif; else: echo "" ;endif; ?>
                                                    </div>

                                                </label>
                                            </div>

                                            <div class="divclear0">
                                            </div>
                                        </li>

                                        <li class="last" cid="0">
                                            <label for="user_consignee_id_0">
                                                
                                                添加新收货地址:</label>
                                        </li>
                                    </ul>
                                    <div class="divclear0">
                                    </div>
                                </div>
                                <div id="user_consignee_info" >
                                    <div class="r-eidt-helptel">

                                    </div>

                                    <ul class="tab_list fl">
                                        <li id="u_c_edit_title_info" >
                                            <div class="u_c_edit_title">
                                                编辑收货地址</div>

                                            
                                        </li>
                                        <li>
                                            <div class="left">
                                                <font class="title">收货姓名：</font>
                                                <input name="name" type="text" class="Usertext" id="name" value="" size="35">
                                                <font>*</font>
                                            </div>
                                            <div class="right">
                                                <span id="CName_tip" class="tip">请填写收货人的真实姓名</span></div>
                                            <div class="divclear0">
                                            </div>
                                        </li>
                                        
                                        <li>
                                            <div class="left">
                                                <font class="title">收货地址：</font>

                                                <input type="text" class="Usertext" id="addr" placeholder="请填写收货人所在地区的街道详细地址。" size="75" value="" name="address">
                                                <font>*</font>
                                            </div>
                                            <div class="right">
                                                <span id="CAddr_tip" class="tip">请填写收货人所在地区的街道详细地址。</span></div>
                                            <div class="divclear0">
                                            </div>
                                        </li>
                                        <li >
                                            <div class="left">
                                                <font class="title">邮政编码：</font>
                                                <input type="text" class="Usertext" id="email" size="35" value="">
                                                <font>*</font>
                                            </div>
                                            <div class="right">
                                                <span id="CZip_tip" class="tip">请输入邮政编码，将有助于快速确定送货地址。</span><span class="tip" 
                                                                                                                  id="c_SetPostalCode"></span></div>
                                            <div class="divclear0">
                                            </div>
                                        </li>
                                        <li>
                                            <div class="left">
                                                <font class="title">手机号码：</font>
                                                <input type="text" class="Usertext" id="tel" size="35" value="">
                                                <font>*</font>
                                            </div>
                                            <div class="right">
                                                <span id="CMobile_tip" class="tip">填写手机号码。</span></div>
                                            <div class="divclear0">
                                            </div>
                                        </li>


                                    </ul>
                                </div>
                                <div class="divclear0"></div>
                                <div class="rinfo_btn address">
                                    <a href="javascript:;" id="btn_save_u_c_info" class="save_u_l_info">
                                        <input type="button" value="送到这个地址" editval="保存并送到这个地址" saveval="送到这个地址" class="save_u_c_info" /></a></div>
                            </div>
                        </div>

                </div>
            </div>

            <div class="rinfo o_goods_rinfo">
                <div class="rinfo_title">
                    <span class="o_t_left"><font>订单商品信息：</font></span> <span class="o_t_right"> </span>
                </div>
                <div class="rinfo_ok" style="border: 1px #ccc solid ">
                    <div class="cart_goods_info">
                        <div id="cart_goods_info">
                            <table cellpadding="0" border="0" cellspacing="0"  class="cart_tab cart_tab_goods" >
                                <thead>
                                    <tr>
                                        <th class="w70">商品图片</th>
                                        <th class="w450">商品名称</th>
                                        <th class="w130">订购价</th>
                                        <th class="w65">数量</th>
                                        <th class="w130">小计</th>
                                    </tr>
                                </thead>
                                <tbody>
                               
                                    <?php if(is_array($order)): $i = 0; $__LIST__ = $order;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><input type="hidden" class="oid" value="<?php echo ($v["id"]); ?>">
                                      <input type="hidden" class="gid" value="<?php echo ($v["gid"]); ?>">
                                       <input type="hidden" class="attrvid" value="<?php echo ($v["attrvid"]); ?>">
                                    <tr class="cartgoods" style="border:1px solid #f8f8f8" days="3">
                                    
                                        <td class="w70"><a  href="<?php echo U('Detail/index',array('id'=>$v['gid']));?>" target=_blank><img style="width:50px;height:50px;" src="<?php echo ($v["path"]); ?>"></a></td>
                                        <td class="w450"><a onfocus=this.blur(); href="<?php echo U('Detail/index',array('id'=>$v['gid']));?>" target=_blank><?php echo ($v["gname"]); echo ($v["attrval"]); ?></a></td>
                                        <td class="w130">￥<?php echo ($v["price"]); ?>元</td>
                                        <td class="w65"><?php echo ($v["sum"]); ?></td>
                                        <td class="w130">￥<?php echo ($v["sumprice"]); ?>元</td>
                                    </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                                </tbody>

                            </table>
                        </div>

                    </div>

                    <div class="o_price_info">

                        <ul style="float: left; width: 610px; margin-top: 40px;">
                            <li class="title" style="padding-left: 0px;">备注：</li>
                            <li class="info">
                                <textarea class="Usertextarea default_color" style="width: 560px; height: 40px; border: 1px solid #ddd;"
                                          id="OMessage" name="OMessage" placeholder="您还有什么叮嘱吗？请告诉我们。"></textarea>
                            </li>
                        </ul>
                        <div class="info">
                            <ul>
                                <li class="left">商品数量：</li>
                                <li><span class="price"><?php echo ($count); ?></span>种</li>
                            </ul>

                           

                            <ul class="boders">
                                <li class="left">共计金额：</li>
                                <li class="CARTPRICE">￥<span id="BoLMoney" class="price"><?php echo ($sumprice); ?></span>元</li>
                            </ul>

                            <div class="divclear0">
                            </div>
                        </div>
                        <div class="divclear0">
                        </div>
                    </div>
                    <div class="divclear0">
                    </div>
                </div>
            </div>
            <div class="divclear">
            </div>
            <div class="o_btn">
                <div class="left">
                    <a onfocus="this.blur();" href="<?php echo U('Cart/index');?>" class="btn_backcart">返回购物车</a>
                </div>
                <div class="right">
                    <input type="hidden" value="OK" name="addOrder">
                    <input id="btn_create_order" type="button" value="确认下单" class="cartsubmit" title="确认无误，下订单">
                    <div id="ErrorTD">
                        <span id="ErrorStr" style="COLOR: #ff0000"></span>
                    </div>
                </div>
            </div>
            <div class="divclear">
            </div>
        </form>
    </div>
</div>
</div>
<script>

 $('.address').click(function(){
    var name = $('#name').val();
    var tel = $('#tel').val();
    var email = $('#email').val();
    var address = $('#addr').val();
    // alert(addr);
    var pattern_name = /^[\u4E00-\u9FA5]{2,6}$/;
        var pattren_tel = /^1[34578]\d{9}$/; 
        var pattren_email = /^[1-9][0-9]{5}$/;
        if (!pattern_name.test(name)) {
         alert('姓名是2到6位汉字组成');
        }else if (address.length == 0) {
          alert('地址不能为空');
        }else if (!pattren_email.test(email)) {
          alert('请填写正确的邮政编码');
        }else if (!pattren_tel.test(tel)) {
          alert('请填写正确的手机号码');
        }else{
            $.post("<?php echo U('Order/address');?>", { name: name, tel: tel,email:email,address:address },
              function(data){
              if ($data.status=1) {
                alert($data.info);
                history.go(0);
              }else{
                alert($data.info);
              }
              });
        }
 }) 
 $('.cartsubmit').click(function(){
   var oid = new Array();
   var aid = $('.aid:checked').val(); 
   var gid = new Array();
   var attrvid = new Array();
   $('.oid').each(function(k,v){
       oid.push($(v).val());
   })
   oid.sort(function(a,b){
         return a-b;
   })
   $('.gid').push(function(k,v){
    gid.push($(v).val());
   })
   gid.sort(function(a,b){
    return a-b;
   })
   $('.attrval').push(function(k,v){
    attrvid.push($(v).val());
   })
   attrvid.sort(function(a,b){
    return a-b;
   })
   $.post("order", { gid: gid, aid: aid,oid:oid,attrvid:attrvid },
   function(data){
    if (data.status==1) {
        alert(data.info);
     window.location.href = '<?php echo U('order/pay');?>'+'?dingdanhao='+data.dingdanhao;
    }else{
        alert(data.info);
    }
    
   });
 })
</script>